package com.huarui.framework.activemq;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.jms.support.converter.MessageConverter;

public class OrderMessageConverter implements MessageConverter {

	@Override
	public Object fromMessage(Message message) throws JMSException,
			MessageConversionException {
		TextMessage tMsg=(TextMessage) message;
		Order order  =new Order();
		order.setId(tMsg.getStringProperty("id"));
		return order;
	}

	@Override
	public Message toMessage(Object object, Session session)
			throws JMSException, MessageConversionException {
		Order order = (Order) object;
		TextMessage   message = session.createTextMessage();
		message.setStringProperty("id", order.getId());
		return message;
	}

}
